Skip to content

Add svd/svdvals support for ROCArray#960

Merged
luraess merged 3 commits into
mainfrom
lr/svd
Jul 6, 2026
Merged

Add svd/svdvals support for ROCArray#960
luraess merged 3 commits into
mainfrom
lr/svd

Conversation

@luraess

@luraess luraess commented Jul 6, 2026

Copy link
Copy Markdown
Member

This PR makes svd / svdvals (and therefore cond) work correctly on ROCArray, fixing #837. Previously they fell through to LinearAlgebra's default divide-and-conquer path (gesdd!), which rocSOLVER doesn't implement.

What this does

  • Adds SVDAlgorithm types — JacobiAlgorithm (gesvdj!) and QRAlgorithm (gesvd!) — and defines svd / svd! / svdvals / svdvals! for ROCMatrix, returning a standard LinearAlgebra.SVD.
  • Default is JacobiAlgorithm, which is fastest on AMD GPUs per @evelyne-ringoot's MI300X benchmarks in SVD not consistently working with ROCArrays #837.
  • Accepts LinearAlgebra.QRIteration() / DivideAndConquer() too (mapped to QR / Jacobi), so the old svd(A; alg=QRIteration()) workaround keeps working.
  • Extends gesvdj! with jobu / jobvt keywords (builds on Add jobu and jobvt parameters to gesvdj! function #864, thanks @evelyne-ringoot), including a 'N' values-only fast path for svdvals; unifies its return with gesvd! to (U, S, Vt).
  • Guardrail: LAPACK.gesdd!(job, ::ROCMatrix) now routes to gesvd!, so no generic path can reach OpenBLAS with a device pointer.

Testing: Regression test for the #837 MWE (svd, cond), plus coverage of both algorithms, full=true/false, square/tall/wide shapes, and all four element types.

Closes #837.
Closes #864 (superseded).

🤖 Generated with Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMDGPU.jl Benchmarks

Details
Benchmark suite Current: 868b495 Previous: c9bb187 Ratio
amdgpu/synchronization/context/device 600 ns 600 ns 1
amdgpu/synchronization/stream/blocking 260 ns 260 ns 1
amdgpu/synchronization/stream/nonblocking 350 ns 360 ns 0.97
array/accumulate/Float32/1d 86812 ns 84521 ns 1.03
array/accumulate/Float32/dims=1 250364 ns 249923 ns 1.00
array/accumulate/Float32/dims=1L 137172 ns 135772 ns 1.01
array/accumulate/Float32/dims=2 129002 ns 134282 ns 0.96
array/accumulate/Float32/dims=2L 2809303 ns 2808118 ns 1.00
array/accumulate/Int64/1d 97561 ns 98071 ns 0.99
array/accumulate/Int64/dims=1 257874 ns 242453 ns 1.06
array/accumulate/Int64/dims=1L 168043 ns 167612 ns 1.00
array/accumulate/Int64/dims=2 123932 ns 127572 ns 0.97
array/accumulate/Int64/dims=2L 2991333 ns 2986440 ns 1.00
array/broadcast 79821 ns 60690 ns 1.32
array/construct 1800 ns 1670 ns 1.08
array/copy 37641 ns 39001 ns 0.97
array/copyto!/cpu_to_gpu 182493 ns 115432 ns 1.58
array/copyto!/gpu_to_cpu 114552 ns 183513 ns 0.62
array/copyto!/gpu_to_gpu 61301 ns 42561 ns 1.44
array/iteration/findall/bool 183802 ns 182932 ns 1.00
array/iteration/findall/int 189063 ns 200213 ns 0.94
array/iteration/findfirst/bool 125941 ns 122221 ns 1.03
array/iteration/findfirst/int 120052 ns 118322 ns 1.01
array/iteration/findmin/1d 171012 ns 172192 ns 0.99
array/iteration/findmin/2d 156922 ns 155922 ns 1.01
array/iteration/logical 356525 ns 352985 ns 1.01
array/iteration/scalar 298004 ns 288944 ns 1.03
array/permutedims/2d 74341 ns 72771 ns 1.02
array/permutedims/3d 73451 ns 73321 ns 1.00
array/permutedims/4d 76820 ns 75921 ns 1.01
array/random/rand/Float32 53450 ns 54461 ns 0.98
array/random/rand/Int64 57030 ns 57061 ns 1.00
array/random/rand!/Float32 89791 ns 86631 ns 1.04
array/random/rand!/Int64 142322 ns 92761 ns 1.53
array/random/randn/Float32 89981 ns 87861 ns 1.02
array/random/randn!/Float32 118091 ns 110492 ns 1.07
array/reductions/mapreduce/Float32/1d 134722 ns 133412 ns 1.01
array/reductions/mapreduce/Float32/dims=1 95432 ns 94591 ns 1.01
array/reductions/mapreduce/Float32/dims=1L 774922 ns 773740 ns 1.00
array/reductions/mapreduce/Float32/dims=2 97751 ns 96191 ns 1.02
array/reductions/mapreduce/Float32/dims=2L 297124 ns 294243 ns 1.01
array/reductions/mapreduce/Int64/1d 135142 ns 129821 ns 1.04
array/reductions/mapreduce/Int64/dims=1 95781 ns 94641 ns 1.01
array/reductions/mapreduce/Int64/dims=1L 784172 ns 785310 ns 1.00
array/reductions/mapreduce/Int64/dims=2 96682 ns 98371 ns 0.98
array/reductions/mapreduce/Int64/dims=2L 296745 ns 301204 ns 0.99
array/reductions/reduce/Float32/1d 134122 ns 132981 ns 1.01
array/reductions/reduce/Float32/dims=1 95362 ns 94951 ns 1.00
array/reductions/reduce/Float32/dims=1L 773382 ns 773631 ns 1.00
array/reductions/reduce/Float32/dims=2 98101 ns 97011 ns 1.01
array/reductions/reduce/Float32/dims=2L 299074 ns 296684 ns 1.01
array/reductions/reduce/Int64/1d 134912 ns 133071 ns 1.01
array/reductions/reduce/Int64/dims=1 95501 ns 94911 ns 1.01
array/reductions/reduce/Int64/dims=1L 783521 ns 780131 ns 1.00
array/reductions/reduce/Int64/dims=2 96791 ns 96751 ns 1.00
array/reductions/reduce/Int64/dims=2L 298274 ns 298174 ns 1.00
array/reverse/1d 43920 ns 43060 ns 1.02
array/reverse/1dL 75621 ns 74391 ns 1.02
array/reverse/1dL_inplace 88262 ns 93081 ns 0.95
array/reverse/1d_inplace 74041 ns 141882 ns 0.52
array/reverse/2d 51291 ns 50520 ns 1.02
array/reverse/2dL 101821 ns 101111 ns 1.01
array/reverse/2dL_inplace 178083 ns 119941 ns 1.48
array/reverse/2d_inplace 74171 ns 139582 ns 0.53
array/sorting/1d 341524 ns 342234 ns 1.00
integration/byval/reference 39461 ns 39380 ns 1.00
integration/byval/slices=1 40420 ns 40441 ns 1.00
integration/byval/slices=2 160932 ns 141762 ns 1.14
integration/byval/slices=3 238843 ns 237423 ns 1.01
integration/volumerhs 5039400 ns 5033928 ns 1.00
kernel/indexing 130552 ns 59441 ns 2.20
kernel/indexing_checked 132062 ns 67040 ns 1.97
kernel/launch 1290 ns 1320 ns 0.98
kernel/rand 197382 ns 122232 ns 1.61
latency/import 1588708614 ns 1581839280 ns 1.00
latency/precompile 36298488918 ns 36431611059 ns 1.00
latency/ttfp 2157371920 ns 2156197272 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@luraess luraess merged commit 71739ff into main Jul 6, 2026
5 checks passed
@luraess luraess deleted the lr/svd branch July 6, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVD not consistently working with ROCArrays

1 participant